using UnityEngine;
/// <summary>让UI始终 面向相机</summary>
public class Billboard : MonoBehaviour
{
    Camera mainCamera = null;
    void Awake()
    {
        mainCamera = Camera.main; // 获取主相机
    }
    void Update()
    {
        if (mainCamera!= null)
        {
            // 将物体的z轴旋转设置为始终面向相机
            transform.LookAt(transform.position + mainCamera.transform.rotation * Vector3.forward,
                mainCamera.transform.rotation * Vector3.up);
        }
    }
}